		TITLE	STRTMAP	- Copyright (c) SLR Systems 1994

		INCLUDE	MACROS
		INCLUDE	EXES

		PUBLIC	ALLOW_START_MAP,DO_START_ADDRESS


		.DATA

		EXTERNDEF	MAPFILE_GINDEX:DWORD,MODEND_ADDRESS:DWORD,WM_START_ADDR:DWORD

		EXTERNDEF	START_DEFINED_SEM:QWORD,NEXEHEADER:NEXE,PEXEHEADER:PEXE


		.CODE	PASS2_TEXT

		EXTERNDEF	_capture_eax:proc
		EXTERNDEF	_release_eax:proc
		EXTERNDEF	_release_eax_bump:proc
		EXTERNDEF	HEXWOUT:PROC,HEADER_OUT:PROC,CAPTURE_EAX:PROC,RELEASE_EAX:PROC


ALLOW_START_MAP	PROC
		;
		;
		;
if	fgh_mapthread
		BITT	_HOST_THREADED
		JZ	DO_START_ADDRESS

		RELEASE	START_DEFINED_SEM

		RET
endif

ALLOW_START_MAP	ENDP


DO_START_ADDRESS	PROC
		;
		;IF START ADDRESS SPECIFIED
		;
		MOV	EAX,MAPFILE_GINDEX

		OR	EAX,EAX
		JZ	L9$

		CMP	MODEND_ADDRESS,0
		JZ	L9$

		CAPTURE	START_DEFINED_SEM
		YIELD				;SO STOP WORKS
		
		MOV	EDI,OFF EPM_CS
		XOR	EDX,EDX
if	fg_pe
		BITT	OUTPUT_PE

		MOV	EAX,PEXEHEADER._PEXE_ENTRY_RVA
		JNZ	L5$
endif
		INC	EDX
if	fg_segm
		BITT	OUTPUT_SEGMENTED

		MOV	EAX,NEXEHEADER._NEXE_CSIP
		JNZ	L5$
endif
if	fg_norm_exe
		MOV	EAX,WM_START_ADDR
endif
L5$:
		PUSH	EAX

		SHR	EAX,16
		CALL	HEXWOUT

		POP	EAX
		ADD	EDI,EDX

		CALL	HEXWOUT

		TEST	EDX,EDX
		JNZ	L6$

		MOV	AL,' '
		STOSB
L6$:

		MOV	EAX,OFF ENTRY_POINT_MSG
		CALL	HEADER_OUT
L9$:
		RET

DO_START_ADDRESS	ENDP


		.DATA

ENTRY_POINT_MSG DB	SIZEOF ENTRY_POINT_MSG-1+SIZEOF EPM_CS+SIZEOF EPM_IP,0DH,0AH,'Program entry point at '
EPM_CS		DB	'0000:'
EPM_IP		DB	'0000',0DH,0AH

		END

